package com.lin.cms.validator;

import org.springframework.validation.Errors;
import org.springframework.validation.ValidationUtils;
import org.springframework.validation.Validator;

import com.lin.cms.domain.ChannelExt;

public class ChannelExtValidator implements Validator {

	@SuppressWarnings("unchecked")
	public boolean supports(Class clazz) {
		return ChannelExt.class.isAssignableFrom(clazz);
	}

	public void validate(Object target, Errors errors) {
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "channelId", "required");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "channelName", "required");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "isStaticChannel", "required");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "isStaticContent", "required");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "isAccessByDir", "required");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "isListChild", "required");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "pageSize", "required");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "hasTitleImg", "required");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "hasContentImg", "required");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "titleImgWidth", "required");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "titleImgHeight", "required");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "contentImgWidth", "required");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "contentImgHeight", "required");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "commentControl", "required");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "allowUpdown", "required");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "isBlank", "required");
	}

}
